package com.tj.collection.controller.admin.request;


import com.fqgj.common.api.ParamsObject;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.exception.common.ApiIllegalArgumentException;
import com.tj.collection.db.domain.Menu;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2016/11/17
 * Time: 下午7:02
 */
public class UpdateMenuVo extends ParamsObject {
    private Long id;
    private String name;
    private String url;
    /**
     * 菜单类型 0-内部使用 1-商户通用
     */
    private Integer menuType = 0;

    public Long getId() {
        return id;
    }

    public UpdateMenuVo setId(Long id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public UpdateMenuVo setName(String name) {
        this.name = name;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public UpdateMenuVo setUrl(String url) {
        this.url = url;
        return this;
    }

    public Integer getMenuType() {
        return menuType;
    }

    public UpdateMenuVo setMenuType(Integer menuType) {
        this.menuType = menuType;
        return this;
    }

    @Override
    public void validate() {

        if (StringUtils.isEmpty(name)) {
            throw new ApiIllegalArgumentException("菜单项名称不能为空");
        }
    }

    public Menu tran2Menu() {
        return new Menu().setKey(name).setValue(url).setMenuType(menuType);
    }
}
